package com.atguigu.resource;

import org.springframework.core.io.UrlResource;

import java.io.IOException;
import java.net.MalformedURLException;

public class UrlResourceDome {
    public static void main(String[] args) throws MalformedURLException {
        loadUrlResource("http://www.baidu.com");
        loadUrlResource("file:log/test.log");
    }

    public static void loadUrlResource(String path) {
        try{
            UrlResource url = new UrlResource(path);
            System.out.println(url.getURL());
            System.out.println(url.getFilename());
            System.out.println(url.getInputStream().read());
            System.out.println("---------------------");
        }catch (MalformedURLException e) {
            throw  new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
